Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed PositionedTapDetector2's transformation of global to local coords #1676

Merged
merged 6 commits into from
Oct 2, 2023

Conversation

bramp
Copy link
Contributor

@bramp bramp commented Oct 2, 2023

Now, before we accept this PR, there are two possible solutions

  1.  // Transform the global coordinate to the local coordinates.
     final renderBox = context.findRenderObject() as RenderBox?;
     final relative = renderBox?.globalToLocal(global);

or

  1. final relative = details.localPosition;

Option 2 is clearly the simplest, but it is unclear to me why that wasn't always the case. Perhaps localPosition wasn't a member when this code was written. (Which btw localPosition was added to flutter ~4 years ago). @TesteurManiak last touched this code ~6 months ago, and perhaps knows why local wasn't used.

@JaffaKetchup
Copy link
Member

I can't think of a reason why we wouldn't use the second option.

I wonder if this will also open up the route to perspective with Transform working properly (to implement tilting)...?

@JaffaKetchup JaffaKetchup changed the title Fixes #1675 where the PositionedTapDetector2 does not correctly transform the global to local coordinates. PositionedTapDetector2 does not correctly transform global coords to local coords Oct 2, 2023
@bramp
Copy link
Contributor Author

bramp commented Oct 2, 2023

From my understanding of localPosition it effectively does the same as my option 1. Also Option 1 will correctly support any transformation, skew,scale,translate,rotate, etc.

I'll amend this to just do option 2. It's less code and simpler.

Copy link
Member

@JaffaKetchup JaffaKetchup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, many thanks once again!

@JaffaKetchup JaffaKetchup changed the title PositionedTapDetector2 does not correctly transform global coords to local coords Fixed PositionedTapDetector2's transformation of global to local coords Oct 2, 2023
@JaffaKetchup JaffaKetchup merged commit c7c6bd0 into fleaflet:master Oct 2, 2023
6 checks passed
@bramp bramp deleted the scale branch October 2, 2023 21:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Tap relative offsets are incorrect when the widget is within a scaling widget
2 participants